// pages/orderhistory/orderhistory.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    current: 'tab1',
    current_scroll: 'tab1',
    // 全部数组
    orderlist:[
    
    ],
    // 待付款
    dfklist:[],
    // 待发货
    dfhlist:[],
    // 待收货
    dshlist:[],
    // 已完成
    ywclist:[]


  },
  

handleChangeScroll ({ detail }) {
  this.setData({
    current_scroll: detail.key
  });
  // console.log({detail});
  var obj={detail}
  // 点击了哪一项
  console.log(obj.detail.key);

  if(obj.detail.key==="tab1"){
    console.log("全部");
    this.onLoad()
    
  }else if(obj.detail.key==="tab2"){
    this.getList()
    // 筛选待付款
    // 改变orderlist数组的值
  const dfklist= this.data.orderlist.filter(item=>{
return item.status===0
    })
    console.log(dfklist);
    this.setData({orderlist:dfklist})

  

  }else  if(obj.detail.key==="tab3"){
    this.getList()
    // // 筛选待发货
    const dfhlist= this.data.orderlist.filter(item=>{
      return item.status===1
          })
          this.setData({orderlist:dfhlist})

  }else if(obj.detail.key==="tab4"){
    this.getList()
    const dshlist= this.data.orderlist.filter(item=>{
      return item.status===2
          })
          this.setData({orderlist:dshlist})

  }else if(obj.detail.key==="tab5"){
    this.getList()
    const ywclist= this.data.orderlist.filter(item=>{
      return item.status===3
          })
          this.setData({orderlist:ywclist})

  }else if(obj.detail.key==="tab6"){
    this.getList()
    const dhhlist= this.data.orderlist.filter(item=>{
      return item.status===4
          })
          this.setData({orderlist:dhhlist})

  }
  else if(obj.detail.key==="tab7"){
    this.getList()
    const hszlist= this.data.orderlist.filter(item=>{
      return item.status===5
          })
          this.setData({orderlist:hszlist})
  }
},
getList(){
  var data=[  {
    id:"1",
    orderid:"SH00000000000000",
    status:0,
    status_text:"待付款",
    price:"20",
    num:1,
    totalprice:"20"
  },
  {
    id:"2",
    orderid:"SH00000000000001",
    status:1,
    status_text:"待发货",
    price:"20",
    num:1,
    totalprice:"20"
  },
  {
    id:"3",
    orderid:"SH00000000000002",
    status:2,
    status_text:"待收货",
    price:"20",
    num:1,
    totalprice:"20"
  },
  {
    id:"4",
    orderid:"SH00000000000003",
    status:3,
    status_text:"已完成",
    price:"20",
    num:1,
    totalprice:"20"
  },
  {
    id:"5",
    orderid:"SH00000000000004",
    status:4,
    status_text:"退换货",
    price:"20",
    num:1,
    totalprice:"20"
  },
  {
    id:"6",
    orderid:"SH00000000000005",
    status:5,
    status_text:"回收站",
    price:"20",
    num:1,
    totalprice:"20"
  },
  {
    id:"7",
    orderid:"SH00000000000006",
    status:5,
    status_text:"回收站",
    price:"20",
    num:1,
    totalprice:"20"
  }]
  console.log(data);
  var list= JSON.parse(JSON.stringify(data))

  this.setData({orderlist:list})
  

},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // console.log(options);
    this.getList()
  
  


  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
   



  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})